<template>
  <div class="img-detail">
    <!-- 头部 -->
    <myhander titleName="图片详情"></myhander>
    <div>
      <h3 class="img-title">{{imgInfo.title}}</h3>
      <p class="img-info">
        <span class="time">{{imgInfo.add_time | fmtTime}}</span>
        <span>{{imgInfo.click}}次点击</span>
        <span>分类：教育</span>
      </p>
    </div>
    <ul>
      <li>
        <vue-preview :slides="imgsList" @close="handleClose"></vue-preview>
      </li>
    </ul>
    <div class="content" v-html="imgInfo.content"></div>
    <!-- 评论 -->
    <comment :id="$route.params.id"></comment>
  </div>
</template>
<script>
import myhander from '@/components/myhander'
import {getThumb, getSmallInfo} from '@/api'
import comment from '@/components/comment'

export default {
  components: {
    myhander,
    comment
  },
  data () {
    return {
      imgInfo: [], // 图片信息
      imgsList: []// 缩列图
    }
  },
  created () {
    this.initImgList()
  },
  methods: {
    initImgList () {
      getThumb(this.$route.params.id)
        .then(res => {
          console.log(res)
          res.message.map(item => {
            item.msrc = item.src
            item.w = 600
            item.h = 400
          })
          this.imgsList = res.message
        })
      getSmallInfo(this.$route.params.id).then(res => {
        console.log(res)
        this.imgInfo = res.message[0]
      })
    },
    handleClose () {
      console.log('close event')
    }

  }
}
</script>
<style lang="scss">
  img {
    width: 100%;
    height: 100%;
  }
  li > div > div{
    display: flex;
    flex-wrap: wrap;
    &>figure{
      width: 33.33%;
    }
  }
</style>

<style lang="scss" scoped>
.img-detail {
  margin-top: 40px;
  margin-bottom: 55px;

  .img-title {
    font-size: 16px;
    font-weight: bold;
  }
  .img-info {
    display: flex;
    justify-content: space-around;
    color: #26a2ff;
    font-size: 14px;
  }
  .content {
    font-size: 14px;
  }
}
</style>
